# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgbase=ibus
pkgname=(ibus libibus)
pkgver=1.5.19
pkgrel=1
pkgdesc="Next Generation Input Bus for Linux"
arch=('x86_64')
url="https://github.com/ibus/ibus/wiki"
license=('LGPL')
depends=('dconf' 'gtk2' 'gtk3' 'hicolor-icon-theme' 'libnotify' 'python-dbus' 'python-gobject'
         'iso-codes' 'python2-gobject2' 'python2-dbus' 'python2-gobject' 'librsvg')
makedepends=('gobject-introspection' 'vala' 'intltool' 'gnome-common' 'gtk-doc' 'gconf' 'qt5-base'
             'cldr-emoji-annotation' 'unicode-character-database' 'unicode-emoji')
options=('!emptydirs')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/ibus/ibus/archive/$pkgver.tar.gz")
sha512sums=('28554a6ffcf4aa3426b9df18ce16790a8f81be09f4bd6733e7f6d9fe9cbb43519e2cbf12bc7b406e1a9deca9ba7f2fa8e1526101661697529aad9f04428bd69a')

prepare() {
  cd ibus-$pkgver
  sed -i 's|$(libibus) $(libibus_emoji_dialog)|$(libibus_emoji_dialog) $(libibus)|' ui/gtk3/Makefile.am
}

build() {
  cd ibus-$pkgver
  ./autogen.sh \
    --prefix=/usr \
    --libexecdir=/usr/lib/ibus \
    --sysconfdir=/etc \
    --disable-gconf \
    --enable-dconf \
    --enable-wayland \
    --enable-gtk-doc \
    --disable-memconf \
    --enable-ui \
    --enable-python-library \
    --with-python=python3 \
    --with-ucd-dir=/usr/share/unicode/
  make
}

package_ibus() {
  depends+=("libibus=$pkgver")
  install=ibus.install

  cd ibus-$pkgver
  make DESTDIR="$pkgdir" install
  make -C src DESTDIR="$pkgdir" uninstall
  make -C bindings DESTDIR="$pkgdir" uninstall
  rm -r "$pkgdir"/usr/lib/python2.7/site-packages/gi # compiled pyc/pyo files were not cleaned
  make DESTDIR="$pkgdir" uninstall-pkgconfigDATA
}

package_libibus() {
  pkgdesc="IBus support library"
  depends=('glib2')

  cd ibus-$pkgver
  make -C src DESTDIR="$pkgdir" install
  make -C bindings DESTDIR="$pkgdir" install
  make DESTDIR="$pkgdir" install-pkgconfigDATA
}
